package com.invengo.module_check.ui.fragment.get_in_car.item;

import com.invengo.library_db.entity.module_check.BookBean;
import com.invengo.module_check.ui.fragment.get_in_car.GetInCarViewModel;

import androidx.annotation.NonNull;
import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;

public class GetInCarItemViewModel extends ItemViewModel<GetInCarViewModel> {
    public SingleLiveEvent<BookBean> book =new SingleLiveEvent<>();
    public SingleLiveEvent<Boolean> isDirtyData =new SingleLiveEvent<>();
    public GetInCarItemViewModel(@NonNull GetInCarViewModel viewModel,BookBean bean) {
     this(viewModel,bean,false);
    }
    public GetInCarItemViewModel(@NonNull GetInCarViewModel viewModel,BookBean bean,boolean isDirty) {
        super(viewModel);
        this.book.postValue(bean);
        this.isDirtyData.postValue(isDirty);
    }

    public BindingCommand removeItem = new BindingCommand(() -> {
        viewModel.onItemRemove(this);
    });

    public int getPosition() {
        return viewModel.getPosition(this) + 1;
    }

}
